#ifndef EXPENSESYSTEM_H
#define EXPENSESYSTEM_H

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <iomanip>
#include <fstream>
#include <sstream>
#include"Item.h"
#include"DateTime.h"
#include"Category.h"

using namespace std;

struct Step{
	string operation;
	string Categoryname;
	int Itemindex;
	stack<Item> cItem;
	string newName;
	int _size;
};

class ExpenseSystem
{
private:
	vector<Category> expenseCategory;
	double _totalBudget;
	int findCategory(string name);
	stack<Step> Backup;
	string _username;

public :
	ExpenseSystem(string username, double totalBudget);

	~ExpenseSystem();
	
	void addCategory(string name);

	void updateCategory(string currentName, string newName);

	void deleteCategory(string name);

	void addItem(string category, DateTime date, string name, double amount, PaymentStatus status);
	
	void updateItem(string category, int index, DateTime date, string name, double amount, PaymentStatus status);

	void deleteItem(string category, int index);

	void search(string category, DateTime date);

	void printSearchResult(string category, const vector<int>& result);

	void undo();

	void calcUsedBudget(const DateTime& date, double& totalUsed, vector<pair<string,double>>& usedBudget);
	
	void printReport(const DateTime& date);

	void printExpense(const DateTime& date);

	void printPayable(const string& purpose);
	
	void storeCategory();

	void storeItem();

	void restoreCategory();

	void restoreItem();
};

#endif